package com.jyxd.web.controller.qualitycontrol;

import com.jyxd.web.config.TenantEnum;
import com.jyxd.web.data.common.Result;
import com.jyxd.web.data.dto.ApacheStatisticsReturnDTO;
import com.jyxd.web.data.dto.HttpResult;
import com.jyxd.web.data.dto.InOutDepartmentDTO;
import com.jyxd.web.data.user.User;
import com.jyxd.web.service.qualitycontrol.QualitycontrolService;
import com.jyxd.web.util.ExcelData;
import com.jyxd.web.util.ExportExcelUtil;
import com.jyxd.web.util.HttpCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 质控管理
 */
@Api(tags = "质控管理")
@Controller
@RequestMapping(value = "/qualityControl")
public class QualityControlController {
    private static Logger logger = LoggerFactory.getLogger(QualityControlController.class);

    @Autowired
    private QualitycontrolService qualityControlService;

    /**
     * 质控--48h再入科--列表展示统计（按天或者按月）
     *
     * @param map
     * @return
     */
    @ApiOperation("质控--48h再入科--列表展示统计（按天或者按月）")
    @RequestMapping(value = "/getFourAndEightList", method = RequestMethod.POST)
    @ResponseBody
    public String getFourAndEightList(@RequestBody(required = false) Map<String, Object> map, HttpSession session) {
        JSONObject json = new JSONObject();
        json.put("code", HttpCode.FAILURE_CODE.getCode());
        json.put("data", new ArrayList<>());
        json.put("msg", "暂无数据");
        List<InOutDepartmentDTO> dayList = qualityControlService.getFourAndEightList(map);//48h再入科--列表展示统计（按天或者按月）
        if (dayList != null && dayList.size() > 0) {
            json.put("data", dayList);
            json.put("msg", "查询成功");
        }
        User user = (User) session.getAttribute("user");
       // ICU/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }

        json.put("code", HttpCode.OK_CODE.getCode());
        return json.toString();
    }

    /**
     * 质控--48h再入科--折线（按天或者按月）
     *转出ICU后48h内重返率
     * @return
     */
    @ApiOperation("质控--48h再入科--折线（按天或者按月）")
    @RequestMapping(value = "/getFourAndEightNum", method = RequestMethod.POST)
    @ResponseBody
    public String getFourAndEightNum(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {
        JSONObject json = new JSONObject();
        json.put("code", HttpCode.FAILURE_CODE.getCode());
        json.put("data", new ArrayList<>());
        json.put("msg", "暂无数据");

        User user = (User) session.getAttribute("user");
        if (user!=null && StringUtils.isNotEmpty(user.getTenantId())){
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)){
                map.put("status",TenantEnum.ICU.getPatientStatus());
            }else  if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)){
                map.put("status",TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        try {
            Map<String, Object> map1 = qualityControlService.getFourAndEightNum(map);//48h再入科--折线
            json.put("data", map1);
            json.put("msg", "查询成功");
            json.put("code", HttpCode.OK_CODE.getCode());
        } catch (Exception e) {
            System.out.println("getNumByExitType:" + e);
        }
        return json.toString();
    }

    /**
     * 质控--48h再入科--导出（按天或者按月）
     *
     * @return
     */
    @ApiOperation("导出48h再入科信息统计excel")
    @RequestMapping(value = "/downloadFourAndEightTotal", method = RequestMethod.POST)
    @ResponseBody
    public void downloadFourAndEightTotal(@RequestBody(required = false) Map<String, Object> map,
                                          HttpServletResponse response,HttpSession session) throws Exception {

        List<InOutDepartmentDTO> downloadList = qualityControlService.getFourAndEightList(map);

        User user = (User) session.getAttribute("user");
        if (user!=null && StringUtils.isNotEmpty(user.getTenantId())){
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)){
                map.put("status",TenantEnum.ICU.getPatientStatus());
            }else  if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)){
                map.put("status",TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        if (downloadList != null && downloadList.size() > 0) {
            ExportExcelUtil.exportExcel(response, "48h再入科信息统计" + System.currentTimeMillis() +
                    ".xls", setExcel48hData(downloadList));
        } else {
            response.getWriter().print("暂无数据");
        }
    }

    /**
     * 质控--非计划转入Icu--列表展示统计（按天或者按月）
     *
     * @param map
     * @return
     */
    @ApiOperation("质控--非计划转入Icu--列表展示统计（按天或者按月）")
    @RequestMapping(value = "/getIcuPlanList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getIcuPlanList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {

        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.getICUPlanNumList(map);
    }

    /**
     * 质控--非计划转入Icu--折线展示统计（按天或者按月）
     *非计划转入ICU率
     * @param map
     * @return
     */
    @ApiOperation("质控--非计划转入Icu--折线展示统计（按天或者按月）")
    @RequestMapping(value = "/getIcuPlanBrokenList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getIcuPlanBrokenList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {

        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }

        return qualityControlService.getICUPlanBrokenList(map);
    }

    /**
     * 质控--非计划转入Icu--导出（按天或者按月）
     *
     * @return
     */
    @ApiOperation("导出非计划转入Icu信息统计excel")
    @RequestMapping(value = "/downloadIcuPlanTotal", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult downloadIcuPlanTotal(@RequestBody(required = false) Map<String, Object> map
            , HttpServletResponse response,HttpSession session) throws Exception {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.downloadIcuPlanTotal(map, response);
    }

    /**
     * ICU患者标化病死指数
     * @param map
     * @return
     */
    @ApiOperation("质控--获取病死质控统计数据--折线展示统计（按天或者按月）")
    @RequestMapping(value = "/getPatientDieBrokenList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getPatientDieList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.getPatientDieList(map);
    }

    @ApiOperation("质控--获取病死质控统计数据--列表展示统计（按天或者按月）")
    @RequestMapping(value = "/getPatientDieList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getPatientDieNumList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.getPatientDieNumList(map);
    }

    @ApiOperation("质控--导出病死质控统计数据（按天或者按月）")
    @RequestMapping(value = "/downloadPatientDieTotal", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult downloadPatientDieTotal(@RequestBody(required = false) Map<String, Object> map, HttpServletResponse response,HttpSession session) throws Exception {

        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }

        return qualityControlService.downloadPatientDieTotal(map, response);
    }

    /**
     * ICU非计划气管插管拔管率
     * @param map
     * @return
     */
    @ApiOperation("质控--获取非计划icu气管插拔管质控统计数据 --折线展示统计（按天或者按月）")
    @RequestMapping(value = "/getIcuIntubationBrokenList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getIcuIntubationList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }

        return qualityControlService.getIcuIntubationList(map);
    }

    @ApiOperation("质控--获取非计划icu气管插拔管质控统计数据--列表展示统计（按天或者按月）")
    @RequestMapping(value = "/getIcuIntubationList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getIcuIntubationNumList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {

        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.getIcuIntubationNumList(map);
    }

    @ApiOperation("质控--导出非计划icu气管插拔管统计数据（按天或者按月）")
    @RequestMapping(value = "/downloadIcuIntubationTotal", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult downloadIcuIntubationTotal(@RequestBody(required = false) Map<String, Object> map, HttpServletResponse response,HttpSession session) throws Exception {

        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }

        return qualityControlService.downloadIcuIntubationTotal(map, response);
    }

    /**
     * 表格数据48h再入科
     *
     * @param list
     * @return
     */
    private ExcelData setExcel48hData(List<InOutDepartmentDTO> list) {
        ExcelData data = new ExcelData();
        data.setName("出入科信息统计表");
        List<String> titles = new ArrayList();
        titles.add("日期");
        titles.add("现有患者");
        titles.add("转入患者");
        titles.add("转出患者");
        data.setTitles(titles);
        if (list != null && list.size() > 0) {
            List<List<Object>> rows = new ArrayList();
            for (InOutDepartmentDTO inOutDepartmentDTO : list) {
                List<Object> row1 = new ArrayList();
                row1.add(inOutDepartmentDTO.getDataTime());
                row1.add(inOutDepartmentDTO.getFourAndEightSum());
                row1.add(inOutDepartmentDTO.getTransferPatientSum());
                row1.add(inOutDepartmentDTO.getFourAndEightRate());
                rows.add(row1);
            }
            data.setRows(rows);
        }
        return data;
    }

    /**
     * 质控--APACHEII--列表展示统计（按天或者按月）
     *
     * @param map
     * @return
     */
    @ApiOperation("质控--APACHEII--列表展示统计（按天或者按月）")
    @RequestMapping(value = "/getAPACHEIIList", method = RequestMethod.POST)
    @ResponseBody
    public Result<?> getAPACHEIIList(@RequestBody(required = false) Map<String, Object> map) {
        JSONObject json = new JSONObject();
        json.put("code", HttpCode.FAILURE_CODE.getCode());
        json.put("data", new ArrayList<>());
        json.put("msg", "暂无数据");
        List<ApacheStatisticsReturnDTO> dayList = qualityControlService.getAPACHEIIList(map);
//        if (dayList != null && dayList.size() > 0) {
//            json.put("data", dayList);
//            json.put("msg", "查询成功");
//        }
//        json.put("code", HttpCode.OK_CODE.getCode());
        return Result.succeed(dayList);
    }

    /**
     * 质控--APACHEII--折线（按天或者按月）
     *
     * @return
     */
    @ApiOperation("质控--APACHEII--折线（按天或者按月）")
    @RequestMapping(value = "/getAPACHEIINum", method = RequestMethod.POST)
    @ResponseBody
    public String getAPACHEIINum(@RequestBody(required = false) Map<String, Object> map, HttpSession session) {
        JSONObject json = new JSONObject();
        json.put("code", HttpCode.FAILURE_CODE.getCode());
        json.put("data", new ArrayList<>());
        json.put("msg", "暂无数据");
        try {
            Map<String, Object> map1 = qualityControlService.getAPACHEIINum(map);
            User user = (User) session.getAttribute("user");
            if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
                String tenantId = user.getTenantId();
                if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                    map.put("status", TenantEnum.ICU.getPatientStatus());
                } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                    map.put("status", TenantEnum.SHENNEI.getPatientStatus());
                }
            }
            json.put("data", map1);
            json.put("msg", "查询成功");
            json.put("code", HttpCode.OK_CODE.getCode());
        } catch (Exception e) {
            System.out.println("getNumByExitType:" + e);
        }
        return json.toString();
    }

    /**
     * 质控--4APACHEII--导出（按天或者按月）
     *
     * @return
     */
    @ApiOperation("APACHEII信息统计excel")
    @RequestMapping(value = "/downloadAPACHEIITotal", method = RequestMethod.POST)
    @ResponseBody
    public void downloadAPACHEIITotal(@RequestBody(required = false) Map<String, Object> map, HttpServletResponse response,HttpSession session) throws Exception {
        List<ApacheStatisticsReturnDTO> downloadList = qualityControlService.getAPACHEIIList(map);
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        if (downloadList != null && downloadList.size() > 0) {
            ExportExcelUtil.exportExcel(response, "APACHEII评分信息统计" + System.currentTimeMillis() + ".xls", setExcelAPACHEIIData(downloadList));
        } else {
            response.getWriter().print("暂无数据");
        }
    }

    /**
     * 表格数据APACHEII
     *
     * @param list
     * @return
     */
    private ExcelData setExcelAPACHEIIData(List<ApacheStatisticsReturnDTO> list) {
        ExcelData data = new ExcelData();
        data.setName("APACHEII评分信息统计表");
        List<String> titles = new ArrayList();
        titles.add("日期");
        titles.add("科室收治数");
        titles.add("大于等25分值患者数");
        titles.add("20-25之间的患者数");
        titles.add("15-20之间的患者数");
        titles.add("10-15之间的患者数");
        titles.add("小于10的患者数");
        titles.add("入科24小时未评分患者数");
        titles.add("大于15分患者收治率");
        data.setTitles(titles);
        if (list != null && list.size() > 0) {
            List<List<Object>> rows = new ArrayList();
            for (ApacheStatisticsReturnDTO apacheStatisticsReturnDTO : list) {
                List<Object> row1 = new ArrayList();
                row1.add(apacheStatisticsReturnDTO.getDateTime());
                row1.add(apacheStatisticsReturnDTO.getDepartmentsNumber());
                row1.add(apacheStatisticsReturnDTO.getGe25Number());
                row1.add(apacheStatisticsReturnDTO.getBetween20Or25Number());
                row1.add(apacheStatisticsReturnDTO.getBetween15Or20Number());
                row1.add(apacheStatisticsReturnDTO.getBetween10Or15Number());
                row1.add(apacheStatisticsReturnDTO.getLe10Number());
                row1.add(apacheStatisticsReturnDTO.getInto24NotPassNumber());
                row1.add(apacheStatisticsReturnDTO.getGreater15Number());
                rows.add(row1);
            }
            data.setRows(rows);
        }
        return data;
    }

    /**
     * 感染性休克3h集束化治疗（bundle）完成率=入icu诊断为感染性休克并全部完成3hbundle的患者数/同期入icu诊断为感染休克患者总数*100%
     */
    @ApiOperation("质控--是否进行感染性休克3h集束化治疗（bundle）完成--列表展示统计（按天或者按月）")
    @RequestMapping(value = "/get3hBundleList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult get3hBundleList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {

        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.get3hBundleNumList(map);
    }

    /**
     * 质控--感染性休克3h集束化治疗（bundle）完成--折线展示统计（按天或者按月）
     *感染性休克3h集束化治疗
     * @param map
     * @return
     */
    @ApiOperation("质控--是否进行感染性休克3h集束化治疗（bundle）完成--折线展示统计（按天或者按月）")
    @RequestMapping(value = "/get3hBundleBrokenList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult get3hBundleBrokenList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.get3hBundleBroken(map);
    }

    /**
     * 质控--感染性休克3h集束化治疗（bundle）完成--导出（按天或者按月）
     *
     * @return
     */
    @ApiOperation("导出感染性休克3h集束化治疗（bundle）完成信息统计excel")
    @RequestMapping(value = "/download3hBundleTotal", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult download3hBundleTotal(@RequestBody(required = false) Map<String, Object> map, HttpServletResponse response,HttpSession session) throws Exception {

        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }

        return qualityControlService.download3hBundleTotal(map, response);
    }

    /**
     * 感染性休克6h集束化治疗（bundle）完成率=入icu诊断为感染性休克并全部完成6hbundle的患者数/同期入icu诊断为感染休克患者总数*100%
     */
    @ApiOperation("质控--是否进行感染性休克6h集束化治疗（bundle）完成--列表展示统计（按天或者按月）")
    @RequestMapping(value = "/get6hBundleList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult get6hBundleList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }

        return qualityControlService.get6hBundleNumList(map);
    }

    /**
     * 质控--感染性休克6h集束化治疗（bundle）完成--折线展示统计（按天或者按月）
     *感染性休克6h集束化治疗
     * @param map
     * @return
     */
    @ApiOperation("质控--是否进行感染性休克6h集束化治疗（bundle）完成--折线展示统计（按天或者按月）")
    @RequestMapping(value = "/get6hBundleBrokenList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult get6hBundleBrokenList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {

        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.get6hBundleBrokenList(map);
    }

    /**
     * 质控--感染性休克6h集束化治疗（bundle）完成--导出（按天或者按月）
     *
     * @return
     */
    @ApiOperation("导出感染性休克6h集束化治疗（bundle）完成信息统计excel")
    @RequestMapping(value = "/download6hBundleTotal", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult download6hBundleTotal(@RequestBody(required = false) Map<String, Object> map, HttpServletResponse response,HttpSession session) throws Exception {

        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }

        return qualityControlService.download6hBundleTotal(map, response);
    }


    /**
     * 是否进行ICU深静脉血栓（DVT）预防
     * ICU深静脉血栓（DVT）=进行深静脉血栓（DVT）预防的ICU患者数/
     * 同期ICU收治患者总数的比例
     * ×100%
     * <p>
     * 感染性休克6h集束化治疗（bundle）完成率=入icu诊断为感染性休克并全部完成6hbundle的患者数/同期入icu诊断为感染休克患者总数*100%
     */
    @ApiOperation("质控--进行ICU深静脉血栓（DVT）预防--列表展示统计（按天或者按月）")
    @RequestMapping(value = "/getDvtList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getDvtList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {

        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.getDvtList(map);
    }

    /**
     * 质控--进行ICU深静脉血栓（DVT）预防--折线展示统计（按天或者按月）
     *ICU深静脉血栓（DVT）预防率
     * @param map
     * @return
     */
    @ApiOperation("质控--是否进行感染性休克6h集束化治疗（bundle）完成--折线展示统计（按天或者按月）")
    @RequestMapping(value = "/getDvtBrokenList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getDvtBrokenList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {

        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.getDvtBrokenList(map);
    }

    /**
     * 质控--进行ICU深静脉血栓（DVT）预防--导出（按天或者按月）
     *
     * @return
     */
    @ApiOperation("导出进行ICU深静脉血栓（DVT）预防统计excel")
    @RequestMapping(value = "/downloadDvtTotal", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult downloadDvtTotal(@RequestBody(required = false) Map<String, Object> map, HttpServletResponse response,HttpSession session) throws Exception {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.downloadDvtTotal(map, response);
    }


    /**
     * 是否进行呼吸机相关性肺炎（VAP）的预防
     * <p>
     * ICU呼吸机相关性肺炎（VAP）发病率=VAP发生例数/同期ICU患者有创机械通气总天数
     * ×
     * 1000‰
     */
    @ApiOperation("质控--是否进行呼吸机相关性肺炎（VAP）的预防--列表展示统计（按天或者按月）")
    @RequestMapping(value = "/getVapList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getVapList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.getVapList(map);
    }

    /**
     * 质控--进行ICU深静脉血栓（DVT）预防--折线展示统计（按天或者按月）
     *ICU呼吸机相关性肺炎（VAP）发病率
     * @param map
     * @return
     */
    @ApiOperation("质控--是否进行呼吸机相关性肺炎（VAP）的预防--折线展示统计（按天或者按月）")
    @RequestMapping(value = "/getVapBrokenList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getVapBrokenList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.getVapBrokenList(map);
    }

    /**
     * 质控--进行ICU深静脉血栓（DVT）预防--导出（按天或者按月）
     *
     * @return
     */
    @ApiOperation("导出进行呼吸机相关性肺炎（VAP）的预防信息统计excel")
    @RequestMapping(value = "/downloadVapTotal", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult downloadVapTotal(@RequestBody(required = false) Map<String, Object> map, HttpServletResponse response,HttpSession session) throws Exception {

        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.downloadVapTotal(map, response);
    }

    /**
     * 患者收治率
     * <p>
     * ICU患者收治率= ICU收治患者总数/同期医院收治患者总数×100% 
     */
    @ApiOperation("质控--患者收治率--列表展示统计（按天或者按月）")
    @RequestMapping(value = "/getPatientGiveList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getPatientGiveList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {

        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.getPatientGiveList(map);
    }

    /**
     * 质控--患者收治率--折线展示统计（按天或者按月）
     *
     * @param map
     * @return
     */
    @ApiOperation("质控--患者收治率--折线展示统计（按天或者按月）")
    @RequestMapping(value = "/getPatientGiveBrokenList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getPatientGiveBrokenList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.getPatientGiveBrokenList(map);
    }

    /**
     * 质控--患者收治率--导出（按天或者按月）
     *
     * @return
     */
    @ApiOperation("导出患者收治率信息统计excel")
    @RequestMapping(value = "/downloadPatientGiveTotal", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult downloadPatientGiveTotal(@RequestBody(required = false)
                                               Map<String, Object> map, HttpServletResponse response,HttpSession session) throws Exception {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.downloadPatientGiveTotal(map, response);
    }

    /**
     * ICU患者收治床日率= ICU收治患者总床日数/同期医院收治患者总床日数×100% 
     */
    @ApiOperation("质控--床日率--列表展示统计（按天或者按月）")
    @RequestMapping(value = "/getBedToDayList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getBedToDayList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.getBedToDayList(map);
    }

    /**
     * 质控--床日率--折线展示统计（按天或者按月）
     *
     * @param map
     * @return
     */
    @ApiOperation("质控--床日率--折线展示统计（按天或者按月）")
    @RequestMapping(value = "/getBedToDayBrokenList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getBedToDayBrokenList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.getBedToDayBrokenList(map);
    }

    /**
     * 质控--床日率--导出（按天或者按月）
     *
     * @return
     */
    @ApiOperation("导出床日率信息统计excel")
    @RequestMapping(value = "/downloadBedToDayTotal", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult downloadBedToDayTotal(@RequestBody(required = false)
                                            Map<String, Object> map, HttpServletResponse response,HttpSession session) throws Exception {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
       return qualityControlService.downloadBedToDayTotal(map, response);
    }

    /**
     * ICU气管插管拔管后48h内再插管率 
     * 定义：气管插管计划拔管后48h内再插管例数占同期ICU患者气管插管拔管总例数的比例。不包括非计划气管插管拔管后再插管。 
     * 计算公式： 
     * = 气管插管计划拔管后48h内再插管例数/同期ICU患者气管插管拔管总例数
     * ×100% 
     * 意义：反映对ICU患者脱机拔管指征的把握能力。
     */
    @ApiOperation("质控--气管插管拔管后48h内再插管率--列表展示统计（按天或者按月）")
    @RequestMapping(value = "/getPipeline48hList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getPipeline48hList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.getPipeline48hList(map);
    }

    /**
     * 质控--气管插管拔管后48h内再插管率--折线展示统计（按天或者按月）
     *
     * @param map
     * @return
     */
    @ApiOperation("质控--气管插管拔管后48h内再插管率--折线展示统计（按天或者按月）")
    @RequestMapping(value = "/getPipeline48hBrokenList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getPipeline48hBrokenList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.getPipeline48hBrokenList(map);
    }

    /**
     * 质控--气管插管拔管后48h内再插管率--导出（按天或者按月）
     *
     * @return
     */
    @ApiOperation("导出气管插管拔管后48h内再插管率信息统计excel")
    @RequestMapping(value = "/downloadPipeline48hTotal", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult downloadPipeline48hTotal(@RequestBody(required = false) Map<String, Object> map,
                                               HttpServletResponse response,HttpSession session) throws Exception {

        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.downloadPipeline48hTotal(map, response);
    }

    /**
     * 细菌感染
     * ICU抗菌药物治疗前病原学送检率= 使用抗菌药物前病原学检验标本送检病例数/
     * 同期使用抗菌药物治疗病例总数
     * ×100% 
     */
    @ApiOperation("质控--细菌感染--列表展示统计（按天或者按月）")
    @RequestMapping(value = "/getBacillosisList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getBacillosisList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.getBacillosisList(map);
    }

    /**
     * 质控--细菌感染--折线展示统计（按天或者按月）
     *ICU抗菌药物治疗前病原学送检率
     * @param map
     * @return
     */
    @ApiOperation("质控--细菌感染--折线展示统计（按天或者按月）")
    @RequestMapping(value = "/getBacillosisBrokenList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getBacillosisBrokenList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.getBacillosisBrokenList(map);
    }

    /**
     * 质控--细菌感染--导出（按天或者按月）
     *
     * @return
     */
    @ApiOperation("导出细菌感染信息统计excel")
    @RequestMapping(value = "/downloadBacillosisTotal", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult downloadBacillosisTotal(@RequestBody(required = false) Map<String, Object> map, HttpServletResponse response,HttpSession session ) throws Exception {

        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.downloadBacillosisTotal(map, response);
    }

    /**
     * crbsi
     * ICU血管内导管相关血流感染（CRBSI）发病率 
     * 定义：CRBSI发生例数占同期ICU患者血管内导管留置总天数的比例。单位：例/千导管日。 
     * 计算公式： 
     * ICU血管内导管相关血流感染（CRBSI）发病率= CRBSI发生例数/同期ICU患者血管内导管留置总天数
     * ×1000‰ 
     */
    @ApiOperation("质控--crbsi--列表展示统计（按天或者按月）")
    @RequestMapping(value = "/getCrbsiList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getCrbsiList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.getCrbsiList(map);
    }

    /**
     * 质控--Crbsi--折线展示统计（按天或者按月）
     *ICU血管内导管相关血流感染（CRBSI）发病率
     * @param map
     * @return
     */
    @ApiOperation("质控--crbsi--折线展示统计（按天或者按月）")
    @RequestMapping(value = "/getCrbsiBrokenList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getCrbsiBrokenList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.getCrbsiBrokenList(map);
    }

    /**
     * 质控--Crbsi--导出（按天或者按月）
     *
     * @return
     */
    @ApiOperation("导出crbsi信息统计excel")
    @RequestMapping(value = "/downloadCrbsiTotal", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult downloadCrbsiTotal(@RequestBody(required = false) Map<String, Object> map, HttpServletResponse response,HttpSession session) throws Exception {

        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.downloadCrbsiTotal(map, response);
    }

    /**
     * cauti
     * <p>
     * ICU血管内导管相关血流感染（CRBSI）发病率 
     * 定义：CRBSI发生例数占同期ICU患者血管内导管留置总天数的比例。单位：例/千导管日。 
     * 计算公式： 
     * ICU血管内导管相关血流感染（CRBSI）发病率= CRBSI发生例数/同期ICU患者血管内导管留置总天数
     * ×1000‰ 
     */
    @ApiOperation("质控--cauti--列表展示统计（按天或者按月）")
    @RequestMapping(value = "/getCautiList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getCautiList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.getCautiList(map);
    }

    /**
     * 质控--cauti--折线展示统计（按天或者按月）
     *icu 导尿管相关泌尿系感染(CAUTI) 发病率
     * @param map
     * @return
     */
    @ApiOperation("质控--cauti--折线展示统计（按天或者按月）")
    @RequestMapping(value = "/getCautiBrokenList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getCautiBrokenList(@RequestBody(required = false) Map<String, Object> map,HttpSession session) {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.getCautiBrokenList(map);
    }

    /**
     * 质控--cauti--导出（按天或者按月）
     *
     * @return
     */
    @ApiOperation("导出cauti统计excel")
    @RequestMapping(value = "/downloadCautiTotal", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult downloadCautiTotal(@RequestBody(required = false) Map<String, Object> map, HttpServletResponse response,HttpSession session) throws Exception {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }

        return qualityControlService.downloadCautiTotal(map, response);
    }

    @ApiOperation("crrt质控数据查询")
    @RequestMapping(value = "/getNewQualitycontrolList", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getNewQualitycontrolList(@RequestBody Map<String, Object> map,HttpSession session) {
        User user = (User) session.getAttribute("user");
        //判断租户是 Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.getNewQualitycontrolList(map);
    }

    @ApiOperation("crrt质控数据查询")
    @RequestMapping(value = "/getCrrtExcel", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getCrrtExcel(@RequestBody Map<String, Object> map, HttpServletResponse response,HttpSession session) {
        User user = (User) session.getAttribute("user");
        // Icu/神内
        if (user != null && StringUtils.isNotEmpty(user.getTenantId())) {
            String tenantId = user.getTenantId();
            if (TenantEnum.ICU.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.ICU.getPatientStatus());
            } else if (TenantEnum.SHENNEI.getTenantId().equals(tenantId)) {
                map.put("status", TenantEnum.SHENNEI.getPatientStatus());
            }
        }
        return qualityControlService.getCrrtExcel(map, response);
    }
}
